package com.qilu.pe.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.qilu.pe.R;
import com.qilu.pe.dao.bean.ItemSet;
import com.ruitu.arad.base.base_list.ListBaseAdapter;
import com.ruitu.arad.base.base_list.SuperViewHolder;

/**
 * <br/>┏------------------------------------------
 * <br/>│Note:
 * <br/>│
 * <br/>┣------------------------------------------
 * <br/>│                 /) /)
 * <br/>│               ฅ(• ﻌ •)ฅ
 * <br/>│  Created by @author HaoKing on 2020/11/02 9:22.
 * <br/>│          www.muchenxinxi.com
 * <br/>│           www.nextdever.com
 * <br/>│           WeChat: NextDever
 * <br/>│             QQ: 773693552
 * <br/>│     QQ Group: Geek Chat 344386592
 * <br/>┗------------------------------------------
 */
public class ProjectItemListAdapter extends ListBaseAdapter<ItemSet> {

    private String orderStatus;

    public ProjectItemListAdapter(Context context) {
        super(context);
    }

    public ProjectItemListAdapter(Context context, String orderStatus) {
        super(context);
        this.orderStatus = orderStatus;
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_confirm_order_item_list;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        TextView tv_name = holder.getView(R.id.tv_name);
        TextView tv_time = holder.getView(R.id.tv_time);
        TextView tv_price = holder.getView(R.id.tv_price);
        TextView vRefund = holder.getView(R.id.vRefund);
        TextView vRefundStatus = holder.getView(R.id.vRefundStatus);

        ItemSet item = mDataList.get(position);

        tv_name.setText(item.getName());
        if (item.getDay() == null) {
            tv_time.setVisibility(View.INVISIBLE);
        } else {
            tv_time.setVisibility(View.VISIBLE);
            tv_time.setText(item.getDay() + "个工作日");
        }
        tv_price.setText("¥" + item.getPrice());

        if ("5".equals(orderStatus)) {
            if (item.getStatus() == 1) {
                vRefundStatus.setVisibility(View.VISIBLE);
                vRefundStatus.setText("退款中");
            } else if (item.getStatus() == 2) {
                vRefundStatus.setVisibility(View.VISIBLE);
                vRefundStatus.setText("已退款");
            } else {
                vRefund.setVisibility(View.VISIBLE);
            }
        }
    }
}
